<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>let and const</title>
</head>
<body>
<script>

    var a =[];
    for(var i=0;i<10;i++){
        a[i] = function () {
            console.log(i);
        };
    }
    a[6]();//10


    var b =[];
    for(let i=0;i<10;i++){
        b[i] = function () {
            console.log(i);
        };
    }
    b[6]();//6

    console.log(window.a)

</script>
</body>
</html>